package com.wang.elasticsearchstudy.goods.controller;

import com.wang.elasticsearchstudy.goods.domain.Goods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/goodsDDL")
public class GoodsDDLController {
    @Autowired
    private ElasticsearchTemplate elasticsearchTemplate;

    /**
     * 创建索引
     */
    @RequestMapping("/createIndex")
    public void createIndex() {
        elasticsearchTemplate.createIndex(Goods.class);
    }

    /**
     * 删除索引
     */
    @RequestMapping("/deleteIndex")
    public void deleteIndex() {
        elasticsearchTemplate.deleteIndex(Goods.class);
    }
}
